package com.xc.h05.controller.wyl;

import com.xc.h05.entity.Mytest;
import com.xc.h05.entity.Systemuser;
import com.xc.h05.service.wyl.MytestService;
import com.xc.h05.service.wyl.SystemuserService;
import com.xc.h05.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/mytest")
public class MytestController {
    @Autowired
    private MytestService mytestservice;

    @GetMapping("/findAll")
    public R findAll(Integer pageNum, Integer pageSize) {
        return R.ok(mytestservice.findAll(pageNum, pageSize));
    }

    @PostMapping()
    public R insert(@RequestBody Mytest mytest) {
        int i = mytestservice.insert(mytest);
        if (i > 0) {
            return R.ok("新增成功");
        } else {
            return R.fail("新增失败");
        }
    }

    @PutMapping()
    public R update(@RequestBody Mytest mytest) {
        int i = mytestservice.update(mytest);
        if (i > 0) {
            return R.ok("修改成功");
        } else {
            return R.fail("修改失败");
        }
    }

    @DeleteMapping("/{id}")
    public R delete(@PathVariable("id")int id) {
        int i = mytestservice.delete(id);
        if (i > 0) {
            return R.ok("删除成功");
        } else {
            return R.fail("删除失败");
        }
    }
}
